/*
----------------------------------------------------------------------------------------------------
This source file is part of the Gamut Framework
Copyright (c) 2007 by Ryan Holcombe

This program is free software; you can redistribute it and/or modify it under the terms of the GNU
Lesser General Public License as published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
----------------------------------------------------------------------------------------------------
*/


#ifndef _GameObjectManager_h_
#define _GameObjectManager_h_

#include "GamutIManager.h"
#include <boost/ptr_container/ptr_map.hpp>


namespace Gamut
{
	class IGameObject;
	
	typedef boost::ptr_map<std::string, IGameObject> GameObjectMap;

	/**
 		Mananges all the game objects
	*/

	class GameObjectManager : public IManager
	{
	private:	
		GameObjectMap mGOMap;						//!< holds all created game objects

	public:
		/** Default constructor
		*/
		GameObjectManager(const std::string& name, unsigned int priority);
		
		
		/** Default deconstructor
			\brief cleans up all undestroyed game objects
		*/
		virtual ~GameObjectManager();
		
		
		/**
			\brief this is run each frame
			\param[in] elapsed time in seconds since the last frame
		*/
		virtual void tick(double elapsed);

		
		/**
			\brief adds a game object to be processed each frame
			\param[in] name unique name for the object
			\param[in] go pointer to an initialised game object
		*/
		virtual void addGameObject(std::string name, IGameObject *go);
		
		
		/**
			\brief destroys a game object
			\param[in] name game object to destroy
		*/
		virtual void destroyGameObject(std::string name);
		
		
		/**
			\brief destroys a game object
			\param[in] go pointer to a Gamut::IGameObject
		*/
		virtual void destroyGameObject(IGameObject *go);
		
		
		/**
			\brief returns a game object
			\param[in] name what the game object is called
			\return a IGameObject pointer to the object, NULL if not found
		*/
		IGameObject* getGameObject(std::string name);

	};
	
}


#endif
